/***************************************************************************
 *   Copyleft 2006-2007 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __GREGORYMANAGER_H__
#define __GREGORYMANAGER_H__

#include "./Cursor3DManager.h"
#include "./BezierCurveManager.h"
#include "./BezierSurfaceManager.h"
#include "./TriGregoryManager.h"
#include "../Objects/Surfaces/GregorySurface.h"

#define BEZIER_SURFACE_COUNT 3

class GregoryManager: public Cursor3DManager {
private:
	
protected:
	enum CreationState {
		FINISHED, 
		CREATED, 
		CURVE_2, 
		CURVE_1, 
		INIT};
	CreationState mCreationState;
	cInt mCreatedSurfaces;
	BezierCurve *mBezierCurve1;
	BezierCurve *mBezierCurve2;
	BezierSurface* mBezierSurfaces[BEZIER_SURFACE_COUNT];
	InputManager *mManager;

	
	virtual cVoid ProceedCreate(Engine3D* engine);
	cVoid CutCurve(BezierCurve *c);
	TriGregory* CreateGregory(Engine3D* engine);

public:

    /**************************************************************
    * Constructors                                                *
    ***************************************************************/
    GregoryManager(Cursor3D* cursor, Engine3D* engine);
    virtual ~GregoryManager(); 
        
    /**************************************************************
    * Operators                                                   *
    ***************************************************************/


    /**************************************************************
    * Other helpful functions                                     *
    ***************************************************************/
	virtual cVoid OnMouseMove(cPoint point, Engine3D* engine);
	virtual cVoid OnMouseWheel(cInt iDelta, Engine3D* engine);
	virtual cVoid OnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam, Engine3D* engine);
	virtual cVoid OnLeftMouseDown(cPoint point, Engine3D* engine);
	virtual cVoid OnLeftMouseUp(cPoint point, Engine3D* engine);
	virtual cVoid OnRightMouseDown(cPoint point, Engine3D* engine);

	virtual Object3D* GetObject();
	cVoid DisplayInfo(Renderer& renderer);
};                                                                 

#endif // __GREGORYMANAGER_H__